home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 August: Tool Chest / Dev.CD Aug 00 TC Disk 2.toast / pc / sample code / quicktime / quicktime vr / vrcursors / testfunctions.c < prev    next >
Encoding:
Text File  |  2000-06-23  |  5.2 KB  |  129 lines

  1. //////////
  2. //
  3. //    File:        TestFunctions.c
  4. //
  5. //    Contains:    Test functions for changing QuickTime VR cursors.
  6. //
  7. //    Written by:    Tim Monroe
  8. //
  9. //    Copyright:    © 1997 by Apple Computer, Inc., all rights reserved.
  10. //
  11. //    Change History (most recent first):
  12. //
  13. //       <1>         06/27/97    rtm        first file: added code to change some hot spot cursors
  14. //       
  15. //////////
  16.  
  17. // header files
  18. #include "TestFunctions.h"
  19. #include "QTVRUtilities.h"
  20.  
  21.  
  22. //////////
  23. //
  24. // A word (or two) on cursors.
  25. //
  26. // Each hot spot type is associated with 3 cursors:
  27. // (1) a cursor that is displayed when it is within the hot spot (the "mouse over" cursor);
  28. // (2) a cursor that is displayed when the mouse button is down in the hot spot (the "mouse down on" cursor);
  29. // (3) a cursor that is displayed when the mouse button is released in the hot spot (the "mouse up on" cursor).
  30. // 
  31. // QuickTime VR defines cursors for several types of hot spots ('link', 'navg', 'stil', 'url ', 'misc', and 'undf').
  32. // To my knowledge, QTVR 2.0 uses only the 'link', 'url ', and 'undf' types. You are free, I think, to create
  33. // hots spots having those other types ('navg', 'stil', and 'misc'). To be safe, however, if you want to attach
  34. // custom cursors to particular types of hot spots, you should probably use some other hot spot type.
  35. // 
  36. // You can use several techniques to attach custom cursors to specific hot spots or to specific types of hot spots.
  37. // The easiest way is to attach the custom cursors at authoring time. This is a two-step process: first, create
  38. // a hot spot information atom for the hot spot. One of the items of data in that atom is an array of three cursor IDs
  39. // for cursors that are to be used instead of the default cursors supplied by QTVR. Then, create resources of type
  40. // 'CURS' having the appropriate IDs and include those resources in the movie file. You can use this technique
  41. // for both format 1.0 and 2.0 QuickTime VR movies. (And, of course, to change the cursors for an entire hot spot
  42. // type, just use the same cursor IDs for all hot spots of that type in the movie.)
  43. //
  44. // To change cursors using the API, you can use the QTVRReplaceCursor function. You can use this function to
  45. // change any of the cursors used by QTVR, not just the hot spot cursors. Here, however, we'll suppose that you want
  46. // to use custom cursors for your own hot spot types. (The same ideas should apply for changing any other cursors.)
  47. // In all likelihood, you'll want to have several types of custom hot spots. By default, QTVR uses a single triplet
  48. // of cursors for *all* undefined hot spot types. So you'll need to replace the undefined cursors dynamically,
  49. // based on the type of custom hot spot. The source file QTVRUtilities.c includes a function QTVRUtils_GetHotSpotType
  50. // that returns the type of a hot spot specified by its ID. We'll use that function to get the type of a hot spot
  51. // whenever an appropriate hot spot action occurs, and change the cursor at that time. (You could probably speed things
  52. // up slightly by building a table of IDs and types, so you don't have to keep looking types up.)
  53. //
  54. //////////
  55.  
  56.  
  57. //////////
  58. //
  59. // MyMouseOverHotSpotProc
  60. // Change cursor when over certain types of hot spots.
  61. //
  62. //////////
  63.  
  64. PASCAL_RTN OSErr MyMouseOverHotSpotProc (QTVRInstance theInstance, UInt32 theHotSpotID, UInt32 theFlags, long theRefCon)
  65. {
  66. #pragma unused(theRefCon)
  67.  
  68.     OSType                myType;
  69.     QTVRCursorRecord    myCursorRec;
  70.     OSErr                myErr = noErr;
  71.  
  72.     // when we first move into a hot spot, set its cursors according to the hot spot type
  73.     if (theFlags == kQTVRHotSpotEnter) {
  74.  
  75.         // get the type of the hot spot, given its ID
  76.         QTVRGetHotSpotType(theInstance, theHotSpotID, &myType);
  77.  
  78.         if (myType == kQTVRHotSpotUndefinedType) {
  79.  
  80.             myCursorRec.theType = kQTVRStdCursorType;
  81.                 
  82.             // change the mouse-over-undefined-hot-spot cursor
  83.             myCursorRec.rsrcID = kCursID_MouseOverUndefHS;
  84.             myCursorRec.handle = (Handle)MacGetCursor(kCursID_MouseOverUndefHS);
  85.             QTVRReplaceCursor(theInstance, &myCursorRec);
  86.             if (myCursorRec.handle != NULL)
  87.                 ReleaseResource(myCursorRec.handle);
  88.             
  89.             // change the mouse-down-on-undefined-hot-spot cursor
  90.             myCursorRec.rsrcID = kCursID_MouseDownOnUndefHS;
  91.             myCursorRec.handle = (Handle)MacGetCursor(kCursID_MouseDownOnUndefHS);
  92.             QTVRReplaceCursor(theInstance, &myCursorRec);
  93.             if (myCursorRec.handle != NULL)
  94.                 ReleaseResource(myCursorRec.handle);
  95.             
  96.             // change the mouse-up-on-undefined-hot-spot cursor
  97.             myCursorRec.rsrcID = kCursID_MouseUpOnUndefHS;
  98.             myCursorRec.handle = (Handle)MacGetCursor(kCursID_MouseUpOnUndefHS);
  99.             QTVRReplaceCursor(theInstance, &myCursorRec);
  100.             if (myCursorRec.handle != NULL)
  101.                 ReleaseResource(myCursorRec.handle);
  102.         }
  103.         
  104.     }
  105.     
  106.     if (theFlags == kQTVRHotSpotLeave) {
  107.             
  108.             myCursorRec.theType = kQTVRUseDefaultCursor;
  109.                 
  110.             // change the mouse-over-undefined-hot-spot cursor
  111.             myCursorRec.rsrcID = kCursID_MouseOverUndefHS;
  112.             myCursorRec.handle = NULL;
  113.             QTVRReplaceCursor(theInstance, &myCursorRec);
  114.             
  115.             // change the mouse-down-on-undefined-hot-spot cursor
  116.             myCursorRec.rsrcID = kCursID_MouseDownOnUndefHS;
  117.             myCursorRec.handle = NULL;
  118.             QTVRReplaceCursor(theInstance, &myCursorRec);
  119.             
  120.             // change the mouse-up-on-undefined-hot-spot cursor
  121.             myCursorRec.rsrcID = kCursID_MouseUpOnUndefHS;
  122.             myCursorRec.handle = NULL;
  123.             QTVRReplaceCursor(theInstance, &myCursorRec);
  124.     }
  125.  
  126.     return(myErr);
  127. }
  128.  
  129.